<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>经济管理学院</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href='css/style.css' type="text/css">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
</head>
<style>
    .fixedTr {
        display: block;
        width: 100%;
    }

    .scrollTd {
        display: block;
        height: 360px;
        overflow: auto;
        width: 100%;
    }

    body {
        background-color: #660099;
    }

    a:visited {
        color: gray;
    }
</style>

<script type='text/javascript' src='js/prototype.js'></script>
<script type='text/javascript' src='js/sha1.js'></script>
<script type='text/javascript' src='js/public.js'></script>
<script type="text/javascript">
    function showuserkey() {
        iteratorLectures();
    }

    function viewLecturesOutline(productId) {
        var params = "lectureId=" + productId;
        new Ajax.Request(
                "json/viewLecturesOutline",
                {
                    method: "post",
                    parameters: params,
                    onComplete: function (request) {
                        var res = request.responseText.evalJSON();
                        if (res["result"]["flag"] == "true") {
                            var grade = " ";
                            if (res["result"]["userEnterYear1"] !== null)
                                grade += res["result"]["userEnterYear1"] + " ";
                            if (res["result"]["userEnterYear2"] !== null)
                                grade += res["result"]["userEnterYear2"] + " ";
                            if (res["result"]["userEnterYear3"] !== null)
                                grade += res["result"]["userEnterYear3"] + " ";
                            if (res["result"]["userEnterYear4"] !== null)
                                grade += res["result"]["userEnterYear4"] + " ";
                            var start = compareTime(res["result"]["startTime"]);
                            var stop = compareTime(res["result"]["stopTime"]);

                            var status = "";
                            if (start == "大于")
                                status += "未到报名时间" + res["result"]["startTime"];
                            if (start == "小于" & stop == "大于")
                                status += "正在报名中 截止时间"
                                        + res["result"]["stopTime"];
                            if (stop == "小于")
                                status += "报名已经截止";
                            var tmp = "<ul style='width:100%; border-bottom:1px  #999 dotted;'><li style='margin-left:20px; margin-top:20px;'><a href='StuOperateLecture-new.html?lectureId="
                                    + res["result"]["lectureId"]
                                    + "'>主题："
                                    + strShorten(res["result"]["lecName"], 40)
                                    + " (点击进行更多操作)</a></li><li style='margin-left:20px;'>主讲人："
                                    + res["result"]["lecSpeaker"]
                                    + "</li><li style='margin-left:20px;'>举办时间："
                                    + res["result"]["lecTime"]
                                    + "</li><li style='margin-left:20px;'>举办地点："
                                    + res["result"]["lecPlace"]
                                    + "</li><li style='margin-left:20px;''>参与年级："
                                    + grade
                                    + "</li><li style='margin-left:20px;''>备注："
                                    + res["result"]["lecNote"]
                                    + "</li><li style='margin-left:20px;'>状态："
                                    + status + "</li></ul>";
                            $("iteratorProductsTarget").innerHTML += tmp;
                            document.getElementById("username").innerHTML = "欢迎 "
                                    + res["result"]["uname"];
                        }
                    },
                    asynchronous: false
                });
    }
    function iteratorLectures() {
        var request = {
            QueryString: function (val) {
                var uri = window.location.search;
                var re = new RegExp("" + val + "=([^&?]*)", "ig");
                return ((uri.match(re)) ? (uri.match(re)[0]
                        .substr(val.length + 1)) : null);
            }
        };
        var max = request.QueryString("max");
        var first = request.QueryString("first");
        if (max == null || first == null) {
            max = 3;
            first = 0;
        }
        var curpage = request.QueryString("curpage");
        if (curpage == null)
            curpage = 1;

        var params = "max=" + max + "&first=" + first;
        new Ajax.Request(
                "json/iteratorLectures",
                {
                    method: "post",
                    parameters: params,
                    onComplete: function (request) {
                        var res = request.responseText.evalJSON();
                        if (res["result"]["flag"] == "true") {
                            for (var i = 0; res["result"]["LectureId" + i] != null; i++) {
                                viewLecturesOutline(res["result"]["LectureId"
                                + i]);
                            }

                            var amount = res["result"]["amountOfLectures"];
                            var CountPage = parseInt(amount / max);
                            if (amount % max > 0)
                                CountPage++;
                            var nextpage = parseInt(curpage) + 1;
                            var prepage = parseInt(curpage) - 1;
                            var last = (CountPage - 1) * max;
                            document.getElementById("amountOfLectures").innerHTML = "共"
                                    + amount + "条记录";
                            document.getElementById("CountPage").innerHTML = "分"
                                    + CountPage + "页";
                            document.getElementById("curpage").innerHTML = "当前第"
                                    + curpage + "页";
                            document.getElementById("firstPage").innerHTML = "<a href='StudentIndex-new.html?max="
                                    + max
                                    + "&first="
                                    + 0
                                    + "&curpage="
                                    + 1
                                    + "' >第一页</a>";
                            document.getElementById("lastPage").innerHTML = "<a href='StudentIndex-new.html?max="
                                    + max
                                    + "&first="
                                    + last
                                    + "&curpage="
                                    + CountPage + "' >尾页</a>";

                            var next = parseInt(first) + parseInt(max) >= parseInt(amount) ? parseInt(amount)
                            - parseInt(max)
                                    : parseInt(first) + parseInt(max);
                            var previous = parseInt(first) - parseInt(max) <= 0 ? 0
                                    : parseInt(first) - parseInt(max);
                            if (prepage > 0)
                                document.getElementById("previous").innerHTML = "<a href='StudentIndex-new.html?max="
                                        + max
                                        + "&first="
                                        + previous
                                        + "&curpage="
                                        + prepage
                                        + "' >上一页</a>&nbsp";
                            if (nextpage <= CountPage)
                                document.getElementById("next").innerHTML = "<a href='StudentIndex-new.html?max="
                                        + max
                                        + "&first="
                                        + next
                                        + "&curpage="
                                        + nextpage + "' >下一页</a>&nbsp";

                        }
                    },
                    asynchronous: false
                });

    }

</script>
<body onload="showuserkey()">
<div class="container">
    <div class="row">
        <div class="col-xs-12" style="text-align:center;color:black;font-size:18px;border-bottom:4px solid #660033">
            经管院学术讲坛事务系统
        </div>
    </div>
    <div class="row">
        <!--div class="col-lg-2 col-md-2 col-sm-2 col-xs-1"></div-->
        <div class="col-lg-4 col-md-4 col-sm-4 col-xs-6" id="username" style="float:left;color:white;">&nbsp;你好</div>
        <div class="col-lg-5 col-md-5 col-sm-5 col-xs-6"><a href="editorUser.html" target="_blank"
                                                            style="text-decoration: none;float:right;">修改密码</a></div>

    </div>
</div>

<div id="main" class="container">
    <div style="width: 100%;position:fixed;font-size: 22px;float:left;">
        <div style="margin-top: 30px; margin-left: 0; height: 560px;">
            <table width=90% border="0"
                   style="font-size: 12px; border: 2px solid #999;">
                <tr class="fixedTr">
                    <td style="border-bottom: 1px #999 dotted;">
                        <li id="firstPage"
                            style="float: left; width: 50px; margin-left: 50px;"></li>
                        <li id="previous" style="float: left; width: 50px"></li>


                        <li id="next" style="float: left; width: 50px;"></li>
                        <li id="lastPage" style="float: left; width: 50px"></li>
                        <br/>
                        <li id="amountOfLectures" style="float: left; width: 80px;margin-left: 50px;"></li>
                        <li id="CountPage" style="float: left; width: 50px"></li>
                        <li id="curpage" style="float: left; width: 80px"></li>
                    </td>
                </tr>
                <tr>
                    <td class="scrollTd" style="font-size: 16px;color:white;">
                        <div id="iteratorProductsTarget">
                        </div>
                    </td>
                </tr>
            </table>


        </div>

    </div>

</div>

</body>
</html>
